<?php
/**
 *
 * @author 天意
 * @version 1.0
 */
class Param{
	private $_params = array();
	public function __construct(){
		$this->init();
	}
	private function init(){
		$var = Regsiter::getInterface();
		$_M = $var->get('Router')->getRouter();
		if(isset($_M['uri'])){
			$uri = $_M['uri'];
			unset($uri[0]);
			$count = count($uri);
			$i = 1;
			$_params['key'] = array();
			$_params['value'] = array();
			while($i <= $count){
				if($i%2){
					$_params['key'][] = $uri[$i];
				}else{
					$_params['value'][] = $uri[$i];
				}
				$i++;
			}
		}
		if(count($_params['key']) > count($_params['value'])){
			array_push($_params['value'],'');
		}
		if(!empty($_params['key']) && !empty($_params['value'])){
			$this->_params = array_combine($_params['key'],$_params['value']);
		}else{
			$this->_params = array();
		}
	}
	public function getParams(){
		return $this->_params;
	}
	public function getParam($param){
		if(isset($this->_params[$param]))
		{
			return $this->_params[$param];
		}
	}
}
